package com.javawork.juc.readWriteLock;

import java.util.concurrent.locks.ReentrantReadWriteLock;

/**
 * @author zhangxiaolu
 * @since 2023-02-19 23:02
 */
public class LockDownGradingDemo {

    public static void main(String[] args) {
        ReentrantReadWriteLock reentrantReadWriteLock = new ReentrantReadWriteLock();

        ReentrantReadWriteLock.ReadLock readLock = reentrantReadWriteLock.readLock();
        ReentrantReadWriteLock.WriteLock writeLock = reentrantReadWriteLock.writeLock();

        writeLock.lock();
        System.out.println("写入");
        readLock.lock();
        System.out.println("读取");
        writeLock.unlock();
        readLock.unlock();
    }
}
